package com.polaris.live.adapter.party

import android.view.View
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterPartyCoverSelectRewardBinding
import com.polaris.live.resp.back_resp.LivePartyGamePriceVo
import com.polaris.live.utils.CommonUtils

/**
 * PartyCoverTypeAdapter
 *
 * @author Created by 半仙 on 2024/3/14/014 22:00
 */
class PartyCoverRewardAdapter :
    BaseBindingAdapter<AdapterPartyCoverSelectRewardBinding, LivePartyGamePriceVo>() {
    private var selectPosition = 0
    override fun convert(
        holder: VBViewHolder<AdapterPartyCoverSelectRewardBinding>,
        item: LivePartyGamePriceVo,
    ) {
        holder.vb.apply {
            partyRewardImg.setImageResource(CommonUtils.invokeGameRewardIcon2(item.assetType))
            if (selectPosition == holder.absoluteAdapterPosition) {
                partyRewardImg.alpha = 1.0f
                partyRewardSelectBack.visibility = View.VISIBLE
            } else {
                partyRewardImg.alpha = 0.5f
                partyRewardSelectBack.visibility = View.GONE
            }
        }
    }

    fun setSelect(position: Int) {
        selectPosition = position
        notifyDataSetChanged()
    }

    fun getSelectItem() = data.getOrNull(selectPosition)

}